THashDictionary< TKey, TObject > Class Template Reference

Hash dictionary template definition. More...

#include <tdictionary.h>

Inheritance diagram for THashDictionary< TKey, TObject >:
Inheritance graph
[legend]

Public Types

typedef uint32(* THashFunc )(const TAssociation< TKey, TObject > &, uint32)
 Hash function type.

Public Member Functions

 THashDictionary (THashFunc hashFunc, int32=10)
 Default constructor.
 THashDictionary (const THashDictionary< TKey, TObject > &)
 Copy constructor.
 ~THashDictionary ()
 Destructor.
THashDictionary< TKey, TObject > & operator= (const THashDictionary< TKey, TObject > &)
 Assignment operator.
bool addKey (const TKey &)
 Add key.
bool addKeyAndObject (const TKey &, const TObject &)
 Add key/object.
bool addAssoc (const TAssociation< TKey, TObject > &)
 Add association.
bool replace (const TKey &, const TObject &)
 Replace object at key.
bool removeKey (const TKey &)
 Remove association at key.
const TKey & lookupKey (const TKey &) const
 Return equal key.
const TObject & lookupObject (const TKey &) const
 Return object by key.
bool containsKey (const TKey &) const
 Test if key is in dictionary.
int32 occurrencesOfKey (const TKey &) const
 How many equal keys.
const TAssociation< TKey,
TObject > & 
lookupAssoc (const TKey &) const
 Lookup association at key.

Detailed Description

template<class TKey, class TObject>
class Steinberg::THashDictionary< TKey, TObject >

Hash dictionary template definition.

A dictionary is a container that holds value pairs, a key and its associated value object.

The difference to the normal TDictionary template is, that THashDictionary gets implemented as a hash table. The interface and usage of both is same.

To understand the benefits and implications of hashes see e.g.: http://en.wikipedia.org/wiki/Hash_table


Member Typedef Documentation

typedef uint32(* THashFunc)(const TAssociation< TKey, TObject > &, uint32)

Hash function type.

Reimplemented from THashTable< TAssociation< TKey, TObject > >.


Constructor & Destructor Documentation

THashDictionary ( THashFunc  hashFunc,
int32  size = 10 
) [inline]

Default constructor.

THashDictionary ( const THashDictionary< TKey, TObject > &  dict  )  [inline]

Copy constructor.

Creates a new dictionary and assigns it with a copy of the specified dictionary.

~THashDictionary (  )  [inline]

Destructor.


Member Function Documentation

THashDictionary< TKey, TObject > & operator= ( const THashDictionary< TKey, TObject > &  dict  )  [inline]

Assignment operator.

Copies the dictionary specified on the right side of the operator into the dictionary on the left side.

bool addKey ( const TKey &  rKey  )  [inline]

Add key.

A new association between the specified key and a default constructed object value gets added.

bool addKeyAndObject ( const TKey &  rKey,
const TObject &  rObj 
) [inline]

Add key/object.

Adds a new association of specified key and object to the dictionary.

bool addAssoc ( const TAssociation< TKey, TObject > &  rAssoc  )  [inline]

Add association.

Adds the specified association to the dictionary.

bool replace ( const TKey &  rKey,
const TObject &  rObj 
) [inline]

Replace object at key.

Finds the first occurrence of an association containing the specified key and replaces its value by the specified object value.

bool removeKey ( const TKey &  rKey  )  [inline]

Remove association at key.

Finds the first association at the specified key and removes it if found.

const TKey & lookupKey ( const TKey &  rKey  )  const [inline]

Return equal key.

Returns the key of the first occurrence of an association containing the specified key.

const TObject & lookupObject ( const TKey &  rKey  )  const [inline]

Return object by key.

Returns a copy of the object of the first occurrence of an association containing the specified key.

bool containsKey ( const TKey &  rKey  )  const [inline]

Test if key is in dictionary.

Returns true if the dictionary contains an association with the specified key.

int32 occurrencesOfKey ( const TKey &  rKey  )  const [inline]

How many equal keys.

Returns the number of associations containing the specified key.

const TAssociation< TKey, TObject > & lookupAssoc ( const TKey &  rKey  )  const [inline]

Lookup association at key.

Returns a copy of the first occurrence of an association containing the specified key.

 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines
Empty

Copyright ©2013 Steinberg Media Technologies GmbH. All Rights Reserved.